-
Notifications
You must be signed in to change notification settings - Fork 13
feat: add code actions, fix ostest & feature flags [IDE-1493] #1054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
19fd1c6 to
45337df
Compare
* test: seperate DIs for TestUnifiedTestApiSmokeTest Previously di.Init() was being called twice in the test. The test have been moved to sub-tests, this way each test only calls it once. * test: make test more robust * test: refactor out duplicate test logic * chore: add test generated files to .gitignore * test: make compare a smoke test Add more test failed to run diags
# Conflicts: # application/server/unified_test_api_smoke_test.go
# Conflicts: # application/server/server_smoke_test.go # infrastructure/oss/cli_scanner.go
- files that are not in workspace folders caused a n nil deference, as the folder was nil and subsequent calls were not taking that scenario into account.
rrama
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit picks and a couple of questions, but nothing blocking getting this merged in.
| repoDir := "1" | ||
| absoluteCloneRepoDir := filepath.Join(tempDir, repoDir) | ||
|
|
||
| if useRootDirDirectly { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit pick: Doing an if and an else would be cleaner.
| t.Setenv("SNYK_LOG_LEVEL", "debug") | ||
| c.SetLogLevel(zerolog.LevelDebugValue) | ||
| t.Setenv("SNYK_LOG_LEVEL", "info") | ||
| c.SetLogLevel(zerolog.LevelInfoValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Why?
| comparisons = append(comparisons, collectOssIdentifiersComparisons(title, unified.Identifiers, legacy.Identifiers)...) | ||
|
|
||
| if unified.Description != legacy.Description { | ||
| if unified.Description[0:20] != legacy.Description[0:20] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should leave a comment explaining that the descriptions are being cut off in the unified scans. We should link to the JIRA bug for it.
| s.mutex.Lock() | ||
| result := s.orgToFlag[org] | ||
| s.orgToFlag.Set(org, orgFlags, imcache.WithExpiration(time.Minute)) | ||
| result := orgFlags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Should this not be a clone, like above?
| return issues, nil | ||
| } | ||
|
|
||
| problem, err := getProblem(trIssue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit pick: Was having it in a function not nicer?
| if err != nil { | ||
| return nil, fmt.Errorf("failed to get and convert primary problem: %w", err) | ||
| } | ||
| func processIssue(ctx context.Context, trIssue testapi.Issue, logger zerolog.Logger, affectedFilePath types.FilePath, filePath types.FilePath, workDir types.FilePath) *snyk.Issue { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit pick: Calling it trIssue is not immediately clear that "tr" stands for "test result". Can we call it unifiedIssue?
| if len(dependencyPath) == 0 { | ||
| return nil | ||
| } | ||
| depPathPackageName := strings.Split(dependencyPath[1], "@")[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit pick: We should probably make the dependency paths be a struct of package name and version with a String() method, as opposed to doing splitting here.
| path = append(path, pkg.Name+"@"+pkg.Version) | ||
| for _, upgradePath := range upgradeAction.UpgradePaths { | ||
| path := upgradePath.DependencyPath | ||
| if len(path) > 0 && path[1].Name == depPathPackageName { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: What is this solving, I couldn't figure out what the bug is without this additional check.
| // If we have upgrade dependencyPath data from the API, use it | ||
| if len(upgradePath) > 1 { | ||
| // Add all packages from upgrade path except the root (skip index 0) | ||
| // Add all packages from upgrade dependencyPath except the root (skip index 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit pick: Find and replace fail?
…k-score-and-fix-issues
Description
This PR refactors the OSS vulnerability processing and feature flag infrastructure, adds risk score display functionality, and improves code maintainability through better separation of concerns.
OSS Issue Processing Refactoring:
addCodeActionsAndLenses()helper function for better testability and reuseossIssueto standalone functions (GetExtendedMessage,createCveLink,createCweLink,createFixedIn,CreateIssueURL,GetCodeActions,AddSnykLearnAction,AddQuickFixAction) - removing tight coupling to the ossIssue structgetAffectedFilePath()helper to reduce code duplicationgetFileContent()into shared utility functionProcessScanResults()signature by using context for dependency injectionGetRemediation()- now only handles upgrade pathsRisk Score Feature (IDE-1493):
RiskScorefield toOssIssueDatastructdetails.html) to conditionally display risk score when non-zeroUseExperimentalRiskScoreandUseExperimentalRiskScoreInCLIto control risk score functionalityFeature Flag Infrastructure Overhaul:
map[string]withimcache.Cachefor both feature flags and SAST settings storageWithProvider()option for cleaner dependency injection and improved testabilityPopulateFolderConfig()now automatically persists folder config viastoredconfig.UpdateFolderConfig()New()constructor with optionsTest Infrastructure Improvements:
Code + Rangeas matching key instead of relying on OssIssueData internal fieldsOther Changes:
Files Changed: 26 files (+549/-588 lines)
Checklist
make generate)make lint-fix)